// pages/cases/detail.js

var api=require("../../utils/api.js");
var WxParse=require("../../wxParse/wxParse.js");
var diyparams=require("../../utils/data.js");

Page({
    data: {
        detail:[],
        citys: []
    },
    onload: function(options){
        this.loaddetail(options.id);
        this.loadswiper();
        this.setData({
            paramsname: diyparams.params
        });
        this.dialog=this.selectComponent("#mydialog");
        this.loadcitys();
    },

    loaddetail(id){
        api.get({
            url: "portal/articles/articles_detail?id="+id,
            success: data=>{
                if(data.code=='1'){
                    WxParse.wxParse("articleContent", "html",data.data.articles.post_content,this,30);
                    this.setData({
                        detail: data.data.articles,
                        adviser: data.data.adviser
                    })
                }
            }
        })
    },

    yuyuefunc(e){
        this.dialog.showModal();
    },

    _hideModal(){
        this.dialog.hideModal();
    },
    formSubmit(e){
        api.post({
            url: "/portal/diyform/insert",
            data: e.detail.value,
            success: data=>{
                if(data.code=='1'){
                    wx.showToast({title: "报名成功", icon: "success"})
                    this.dialog.hideModal();
                }
                if(data.code=='0'){
                    wx.showToast({title: data.msg, icon: "none"})
                }
            }
        })
    },

    loadswiper(){
        api.get({
            url: "home/slides/8",
            success: data=>{
                if(data.code==1){
                    this.setData({
                        movies: data.data[0].items
                    })
                }
            }
        });
    },

    loadcitys(){
        api.get({
            url: "home/attribute/11",
            success: data=>{
                if(data.code==1){
                    this.dialog.setparam(data.data[0].items);
                    this.setData({
                        citys: data.data[0].items
                    })
                }
            }
        });
    },

    onReady: function(){},
    onShow: function(){},
    onHide: function(){},
    onUnload: function(){},
    onPullDownRefreash: function(){},
    onReachBottom: function(){},
    onShareAppMessage: function(){}
})